<html>
<head><meta charset="utf-8"><title>Allow expression for doc(alias) too · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Allow.20expression.20for.20doc(alias).20too.html">Allow expression for doc(alias) too</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="221145195"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Allow%20expression%20for%20doc%28alias%29%20too/near/221145195" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Allow.20expression.20for.20doc(alias).20too.html#221145195">(Dec 29 2020 at 16:16)</a>:</h4>
<p>In <a href="https://github.com/rust-lang/rust/pull/78837">https://github.com/rust-lang/rust/pull/78837</a>, <span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> added support for <code>#[attr = $expr]</code>. However, as I pointed out here: <a href="https://github.com/rust-lang/rust/issues/78835#issuecomment-752127201">https://github.com/rust-lang/rust/issues/78835#issuecomment-752127201</a>, it doesn't work for the "inner" parts. I was looking into it but can't seem to find out where this transformation needs to be added for the "inner" parts too. If someone has a lead, it'd be super useful!</p>



<a name="221151981"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Allow%20expression%20for%20doc%28alias%29%20too/near/221151981" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Allow.20expression.20for.20doc(alias).20too.html#221151981">(Dec 29 2020 at 17:42)</a>:</h4>
<p>See <a href="https://internals.rust-lang.org/t/macro-expansion-points-in-attributes/11455">https://internals.rust-lang.org/t/macro-expansion-points-in-attributes/11455</a> for some background behind <code>#[attr = $expr]</code>.</p>



<a name="221152043"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Allow%20expression%20for%20doc%28alias%29%20too/near/221152043" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Allow.20expression.20for.20doc(alias).20too.html#221152043">(Dec 29 2020 at 17:43)</a>:</h4>
<p><code>#[attr = $expr]</code> must keep working because it works on stable and is widely used, so it's special cased.</p>



<a name="221152197"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Allow%20expression%20for%20doc%28alias%29%20too/near/221152197" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Allow.20expression.20for.20doc(alias).20too.html#221152197">(Dec 29 2020 at 17:45)</a>:</h4>
<p>In case of <code>#[attr(any arbitrary tokens)]</code> <code>any arbitrary tokens</code> are indeed arbitrary, there are no "key-value" pairs there in general, and supporting expansion there is a problem that is entirely separate from <code>#[attr = $expr]</code>.</p>



<a name="221152412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Allow%20expression%20for%20doc%28alias%29%20too/near/221152412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Allow.20expression.20for.20doc(alias).20too.html#221152412">(Dec 29 2020 at 17:48)</a>:</h4>
<p>Supporting it is more or less similar to eager expansion in both language/compiler area (requires some common design work) and in priority (not now).</p>



<a name="221163275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Allow%20expression%20for%20doc%28alias%29%20too/near/221163275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Allow.20expression.20for.20doc(alias).20too.html#221163275">(Dec 29 2020 at 20:12)</a>:</h4>
<p>Is it ok to only allow it for <code>doc(alias)</code> maybe?</p>



<a name="221163290"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Allow%20expression%20for%20doc%28alias%29%20too/near/221163290" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Allow.20expression.20for.20doc(alias).20too.html#221163290">(Dec 29 2020 at 20:12)</a>:</h4>
<p>It's pretty common there to generate code and doc alongside after all</p>



<a name="221163309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Allow%20expression%20for%20doc%28alias%29%20too/near/221163309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Allow.20expression.20for.20doc(alias).20too.html#221163309">(Dec 29 2020 at 20:12)</a>:</h4>
<p>For now I'm trying to integrate it into <code>parse_meta_item_kind</code> but not sure if it's the right place</p>



<a name="221163563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Allow%20expression%20for%20doc%28alias%29%20too/near/221163563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Allow.20expression.20for.20doc(alias).20too.html#221163563">(Dec 29 2020 at 20:16)</a>:</h4>
<p>Please don't, it's an enormous hack.<br>
You can see <code>doc(include)</code> doing something similar, but that's exactly the reason why I went on crusade against it in <a href="https://github.com/rust-lang/rust/issues/44732">#44732</a>.</p>



<a name="221163634"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Allow%20expression%20for%20doc%28alias%29%20too/near/221163634" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Allow.20expression.20for.20doc(alias).20too.html#221163634">(Dec 29 2020 at 20:17)</a>:</h4>
<p>Do you have another suggestion to allow it then? It'd be very nice to have it and it would be more "in phase" with the <code>#[doc = $expr]</code>.</p>



<a name="221167033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Allow%20expression%20for%20doc%28alias%29%20too/near/221167033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Allow.20expression.20for.20doc(alias).20too.html#221167033">(Dec 29 2020 at 21:06)</a>:</h4>
<p>No, my only suggestion would be to not do it now.</p>



<a name="221167552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Allow%20expression%20for%20doc%28alias%29%20too/near/221167552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Allow.20expression.20for.20doc(alias).20too.html#221167552">(Dec 29 2020 at 21:13)</a>:</h4>
<p>Well, I can't do much about it then... Is it scheduled in the future maybe?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>